define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function() {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'clothmaking_coating/index/index' + location.search,
                    add_url: 'clothmaking_coating/index/add',
                    edit_url: 'clothmaking_coating/index/edit',
                    del_url: 'clothmaking_coating/index/del',
                    multi_url: 'clothmaking_coating/index/multi',
                    import_url: 'clothmaking_coating/index/import',
                    table: 'clothmaking_coating',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        { checkbox: true },
                        { field: 'id', title: __('Id') },
                        { field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                        { field: 'starttime', title: __('Starttime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                        { field: 'temperature', title: __('Temperature'), operate: 'BETWEEN' },
                        { field: 'prospeed', title: __('Prospeed'), operate: 'LIKE' },
                        { field: 'oven_temperature', title: __('Oven_temperature'), operate: 'BETWEEN' },
                        { field: 'tension', title: __('Tension'), operate: 'LIKE' },
                        { field: 'pet_specification', title: __('Pet_specification'), operate: 'LIKE' },
                        { field: 'machineNo', title: __('Machineno'), operate: 'LIKE' },
                        { field: 'head_size', title: __('Head_size'), operate: 'LIKE' },
                        { field: 'hose_size', title: __('Hose_size'), operate: 'LIKE' },
                        { field: 'filter1', title: __('Filter1') },
                        { field: 'filter2', title: __('Filter2') },
                        { field: 'before_pressure', title: __('Before_pressure'), operate: 'LIKE' },
                        { field: 'after_pressure', title: __('After_pressure'), operate: 'LIKE' },
                        { field: 'freezer_temperature', title: __('Freezer_temperature'), operate: 'BETWEEN' },
                        { field: 'mixer', title: __('Mixer'), operate: 'LIKE' },
                        { field: 'mixer gasket', title: __('Mixer gasket'), operate: 'BETWEEN' },
                        { field: 'mixer_speed', title: __('Mixer_speed'), operate: 'LIKE' },
                        { field: 'mixer_temperature', title: __('Mixer_temperature'), operate: 'BETWEEN' },
                        { field: 'mixer_pressure', title: __('Mixer_pressure'), operate: 'LIKE' },
                        { field: 'stock _temperature', title: __('Stock _temperature'), operate: 'BETWEEN' },
                        { field: 'discharge_temperature_left', title: __('Discharge_temperature_left'), operate: 'BETWEEN' },
                        { field: 'discharge_temperature_center', title: __('Discharge_temperature_center'), operate: 'BETWEEN' },
                        { field: 'discharge_temperature_right', title: __('Discharge_temperature_right'), operate: 'BETWEEN' },
                        { field: 'isfrozen', title: __('Isfrozen') },
                        { field: 'after_freezing_temperature', title: __('After_freezing_temperature'), operate: 'BETWEEN' },
                        { field: 'user_id', title: __('User_id') },
                        { field: 'customformid', title: __('Customformid') },
                        { field: 'planid', title: __('Planid') },
                        { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function() {
            Controller.api.bindevent();
        },
        edit: function() {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function() {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});